package com.pro.xwt.rest.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pro.xwt.common.model.BDictionary;
import com.pro.xwt.common.model.BEmployee;
import com.pro.xwt.common.service.BDictionaryService;
import com.pro.xwt.common.service.BEmployeeService;
import com.pro.xwt.rest.ResponseResult;

@Controller
@RequestMapping("/departments")
public class BDictionaryController {
	@Autowired
	BDictionaryService bDictionaryService;
	@Autowired
	BEmployeeService bEmployeeService;

	/**
	 * 
	 * 部门查询接口
	 * 
	 * @return
	 */
	@RequestMapping(method = { RequestMethod.GET }, value = "")
	@ResponseBody
	public ResponseResult get() {
		Map<String,Object> map = new HashMap<>();
		map.put("dictType", "DEPARTMENT");
		List<BDictionary> list = bDictionaryService.queryListAll(map);
		return ResponseResult.success("获取资源成功", list);
	}

	/**
	 * 
	 * 部门雇员查询
	 * 
	 * @return
	 */
	@RequestMapping(method = { RequestMethod.GET }, value = "/{id}/employees")
	@ResponseBody
	public ResponseResult getEmp(@PathVariable String id) {
		Map<String, Object> map = new HashMap<>();
		map.put("departmentId", id);
		map.put("deleteState", "0");
		List<BEmployee> list = bEmployeeService.queryListAll(map);
		return ResponseResult.success("获取资源成功", list);
	}

}
